/**
 * LoanConsole.java
 * 
 * author: Zhiqiang Zhu
 * date: Nov/27/2020
 */
package views;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * class LoanConsole 
 * To output all the records from the recordset in console.
 */
public class LoanConsole {
	public void output(ResultSet rs) {
		try {
			
			System.out.println("\n==================== Loan Details ====================");
			System.out.println("PID\t\tID\t\tINCOME\t\tPEP");
			System.out.println("----------------------------------------------------------");
			
			rs.beforeFirst();

			while (rs.next()) {
				System.out.printf("%d\t\t%s\t\t%9.2f\t%s\n", 
				rs.getInt(1),
				rs.getString(2),
				rs.getDouble(3),
				rs.getString(4)
				);
			}

			//rs.close(); // close ResultSet instance
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
